##SHRINK_SAFE_URL = "http://alex.dojotoolkit.org/shrinksafe/shrinksafe.php"
SHRINK_SAFE_URL = "http://auction1.taobao.com/auction/item_detail-db2-104c1e2502c9dc87748d0b3976c7e655.jhtml"
SHRINK_SAFE_DATA_BOUNDARY = "---------------------------72288400411964641492083565382"
SHRINK_SAFE_DATA = '''
--%s\nContent-Disposition: form-data; name="shrinkfile[]"; filename="%s"
Content-Type: application/x-javascript

%s
'''
if __name__=='__main__':
    import sys
    import urllib2
    if len(sys.argv) <2 :
        print('usage:%s src_file' % sys.argv[0])
        sourceFilename = './test.js'
##        exit()
    else:
        sourceFilename = sys.argv[1]
    sourceCode = open(sourceFilename).read()
    
    req = urllib2.Request(url=SHRINK_SAFE_URL,
                          headers={'Content-Type' : 'multipart/form-data; boundary=%s'%SHRINK_SAFE_DATA_BOUNDARY},
                          data=SHRINK_SAFE_DATA % (SHRINK_SAFE_DATA_BOUNDARY, sourceFilename, sourceCode) )
    f = urllib2.urlopen(req)
    print f.read()
    f.close()


    
